package com.hopu.aop.proxy.jdkproxy;

import com.hopu.aop.proxy.IComputerSell;
import com.hopu.aop.proxy.MiComputerFactory;
import com.hopu.aop.proxy.proxy.IPhoneSell;
import com.hopu.aop.proxy.proxy.MiPhoneFactory;

public class ProxyTest {

    public static void main(String[] args) {
        //创建被代理对象
        IComputerSell sell1 = new MiComputerFactory();
        IPhoneSell sell2 = new MiPhoneFactory();
        //创建动态代理对象用于生成代理
        MyJDKProxyShop shop = new MyJDKProxyShop();
        //创建卖电脑的动态代理对象
        IComputerSell proxy = (IComputerSell) shop.createProxy(sell1);
        //调用代理对象
        proxy.sellComputer();
        //创建卖手机的动态代理对象
        IPhoneSell proxy1 = (IPhoneSell) shop.createProxy(sell2);
        proxy1.sellPhone();
    }
}
